package com.boot.notes.rocketmq.praise;


import com.boot.common.constant.RocketConstant;
import com.boot.common.constant.rocket.TopicConstant;
import com.boot.common.utils.R;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@RequestMapping("/message")
public class MessageController {
    @Resource
    private RocketMQTemplate rocketMQTemplate;

    @PostMapping("/praise")
    public R praise(@RequestBody PraiseRecord vo) {
        rocketMQTemplate.sendOneWay(TopicConstant.PRAISE_TOPIC, MessageBuilder.withPayload(vo).build());
        return R.ok();
    }
}
